<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
    <style type="text/css">
        .select {
            display: inline;
        }
    </style>
</head>
<body style="background-color: #fff;">

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;text-align: center;font-family: kaiti;">
    <legend>修改教师信息</legend>
</fieldset>

<div style="width: 500px; margin: 15px auto;padding: 15px;border: 2px solid #666;background-color: #fff;">
    <form  action="__CONTROLLER__/update" method="post">
        <div class="layui-form-item" style="width: 400px;">
            <label class="layui-form-label">教师编号</label>
            <input type="hidden" name="teacher_id"  value={$teacher_id}>
            <div class="layui-input-block" style="padding-top: 10px">
                {$teacher_id}
            </div>
        </div>

        <div class="layui-form-item" style="width: 400px;">
            <label class="layui-form-label">教师姓名</label>
            <div class="layui-input-block">
                <input type="text" name="teacher_name" class="layui-input" value="{$teacher_name}" id="t_name">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <if condition="$sex eq 1">
                    <input style="display: inline;margin-top: 14px;" type="radio" name="sex" value="1" title="男"
                           checked>&nbsp;男&nbsp;
                    <input style="display: inline;margin-top: 14px;" type="radio" name="sex" value="2" title="女">&nbsp;女&nbsp;
                    <else/>
                    <input style="display: inline;margin-top: 14px;" type="radio" name="sex" value="1" title="男">&nbsp;男&nbsp;
                    <input style="display: inline;margin-top: 14px;" type="radio" name="sex" value="2" title="女"
                           checked>&nbsp;女&nbsp;
                </if>
            </div>
        </div>

        <div class="layui-form-item"  style="width: 400px;">
            <label class="layui-form-label">职称</label>
                <!--添加隐藏域-->
                <input type="hidden" name="select" id="hidden_title_value" value={$title_name}>
                <select name="title_name" id="title" lay-filter="aihao" class="col-a" id="title">
                    <option value=""></option>
                    <foreach name="title_info" item="title">
                        <option value="{$title.title_name}">{$title.title_name}</option>
                    </foreach>
                </select>
        </div>

        <div class="layui-form-item"  style="width: 400px;">
            <label class="layui-form-label">所属单位</label>
                <!--添加隐藏域-->
                <input type="hidden" name="select" id="hidden_college_value" value={$college_name}>
                <select name="college_name" id="college" lay-filter="aihao" class="col-a" id="college">
                    <option value=""></option>
                    <foreach name="college_info" item="college">
                        <option value="{$college.college_name}">{$college.college_name}</option>
                    </foreach>
                </select>
        </div>
        
        <div class="layui-form-item" style="width: 400px;">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" class="layui-input" value="{$password}">
            </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">用户权限</label>
            <div class="layui-input-block">
                <if condition="$type eq 1">
                    <input style="display: inline;margin-top: 14px;" type="radio" name="type" value="1" title="教师"
                           checked>&nbsp;教师&nbsp;
                    <input style="display: inline;margin-top: 14px;" type="radio" name="type" value="2" title="管理员">&nbsp;管理员&nbsp;
                    <else/>
                    <input style="display: inline;margin-top: 14px;" type="radio" name="type" value="1" title="教师">&nbsp;教师&nbsp;
                    <input style="display: inline;margin-top: 14px;" type="radio" name="type" value="2" title="管理员"
                           checked>&nbsp;管理员&nbsp;
                </if>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="note" placeholder="添加备注" class="layui-textarea">{$note}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="submit" value="确定" class="layui-btn" id="sure">
                <!-- <button type="reset" class="layui-btn" >重置</button> -->
                <a href="http://www.sinon.com/index.php/Admin/Teacher/index" class="layui-btn">取消</a>
            </div>
        </div>
    </form>
</div>
</body>
</html>

<script>
    //设置院系
    var college_count = $("#college option").length;
    var college_text = $("#hidden_college_value").val();
    for (var i = 0; i < college_count; i++) {
        if ($("#college ").get(0).options[i].text == college_text) {
            $("#college ").get(0).options[i].selected = true;
            break;
        }
    }
    //设置职称
    var title_count = $("#title option").length;
    var title_text = $("#hidden_title_value").val();
    for (var i = 0; i < title_count; i++) {
        if ($("#title ").get(0).options[i].text == title_text) {
            $("#title ").get(0).options[i].selected = true;
            break;
        }
    }

    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');
    });

    $('#sure').on('click', function(){
        var tid = $('#t_id').val();
        var tname = $('#t_name').val();
        var col = $('#college').val();
        var tit = $('#title').val();
        var pwd = $('#pwd').val();

        if(tid==''||tname==''||col==''||tit==''){
            layer.msg('请填写完整数据');
            return false;
        }
    }); 

    $(document).ready(function(){
        $('input').attr('autocomplete', 'off'); 
    })
</script>

<style>
    .layui-form-select .layui-edge {
        position: absolute;
        right: 60px;
        top: 50%;
        margin-top: -3px;
        cursor: pointer;
        border-width: 6px;
        border-top-color: #c2c2c2;
        border-top-style: solid;
        transition: all .3s;
        -webkit-transition: all .3s;
    }
    .layui-input, .layui-textarea {
        display: block;
        width: 250px;
        padding-left: 10px;
    }
    .layui-form-select dl dd, .layui-form-select dl dt {
        padding: 6px 21px;
        line-height: 35px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .layui-form-select dl {
        left: 100px;
        min-width: 62%;
    }

    .col-a{
        padding-right: 30px;
        cursor: pointer;
        border-color: #D2D2D2!important;
        display: block;
        width: 250px;
        padding-left: 10px;
        height: 38px;
        line-height: 1.3;
        border-width: 1px;
        border-style: solid;
        background-color: #fff;
        border-radius: 2px;
    }

</style>

</body>
</html>